﻿using System.Reflection;

namespace CoreEx.DynamicInvoker
{
    /// <summary>
    /// Represents a class that is capable of invoking a specified member.
    /// </summary>
    public interface IMemberInvoker
    {
        /// <summary>
        /// Invokes the specified instance member identified by the <paramref name="memberInfo"/>
        /// </summary>
        /// <param name="target">The target on witch to invoke the member.</param>
        /// <param name="memberInfo">The member to invoke.</param>
        /// <param name="arguments">An array containing the arguments used to invoke the member.</param>
        /// <returns>An <see cref="object"/> representing the return value of the invoked member.</returns>
        object Invoke(object target, MemberInfo memberInfo, object[] arguments);

        /// <summary>
        /// Invokes the specified static/shared member identified by the <paramref name="memberInfo"/>
        /// </summary>       
        /// <param name="memberInfo">The member to invoke.</param>
        /// <param name="arguments">An array containing the arguments used to invoke the member.</param>
        /// <returns>An <see cref="object"/> representing the return value of the invoked member.</returns>
        object Invoke(MemberInfo memberInfo, object[] arguments);

        /// <summary>
        /// Creates a <see cref="MethodHandler"/> delegate that can be used to invoke the member.
        /// </summary>
        /// <param name="memberInfo">The member to invoke.</param>
        /// <param name="arguments">An array containing the arguments used to invoke the member.</param>
        /// <returns>A <see cref="MethodHandler"/> delegate.</returns>
        MethodHandler CreateDelegate(MemberInfo memberInfo, object[] arguments);
    }
}
